Skip to content

Conversation

thestinger
Copy link
Contributor

I didn't add an equivalent free function for map_consume_default, mutate and mutate_default because as far as I can tell the only purpose of the free function versions is backwards compatibility.

The mutate methods are based on a need I have in my balanced tree implementation, which arises from doing it entirely without Copy/Clone. It factors out variations of the following pattern which occurs many times:

if foo.inner_option.is_some() {
    let inner = swap_unwrap(&mut foo.inner_option);
    inner = transform(inner);
    foo.inner_option = Some(inner);
}

catamorphism added a commit that referenced this pull request Jan 13, 2013
improvements to option module
@catamorphism catamorphism merged commit 7eae397 into rust-lang:incoming Jan 13, 2013
@catamorphism
Copy link
Contributor

Thanks!

@thestinger thestinger deleted the option branch January 14, 2013 06:29
RalfJung added a commit to RalfJung/rust that referenced this pull request Jul 16, 2025
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants